define(function(require, exports, module) {
	//初始化ajax配置，如全局配置超时等配置
	var $ = require("jquery");
	var layer = require("layer");
	var resize = require("js/resize");
	//ajax插件分封装
	require("js/ajax");
	//以下是路由设置
	var router = require("js/router");
	router.init();
	//菜单模块
	var menuModule = require("modules/menu/main");
	$.http.get("/menu").then(function (res) {
		//菜单初始化
		menuModule.init(res);
		// JS模块路由表，URL对应JS模块
		var menus = res.data;
		for(var i = 0 ; i < menus.length ; i++){
			var menu = menus[i];
			if(!menu.children){
				//添加缓存权限
				if(menu.permission != null){
					store.permission.push(menu.permission);
				}
				//添加按钮权限
				var bs = menu.btn;
				if(bs == null || bs.length == 0){
					continue;
				}
				for (var k = 0 ; k < bs.length ; k++){
					if(bs[k].permission != null) {
						store.permission.push(bs[k].permission);
					}
				}
				var location = new Array();
				location.push("<a href='#"+menu.url+"'>"+menu.name+"</a>");
				router.registerAsync(menu.url ,location);
				continue;
			}
			var children = menu.children;
			for(var j = 0 ; j < children.length ; j++) {
				var item = children[j];
				//添加缓存权限
				if(item.permission != null){
					store.permission.push(item.permission);
				}
				//添加按钮权限
				var bs = item.btn;
				if(bs == null || bs.length == 0){
					continue;
				}
				for (var k = 0 ; k < bs.length ; k++){
					if(bs[k].permission != null) {
						store.permission.push(bs[k].permission);
					}
				}
				var location = new Array();
				location.push(menu.name);
				location.push("<a href='#"+item.url+"'>"+item.name+"</a>");
				router.registerAsync(item.url , location);
			}
		}
		router.handleAfterRegister();
	}).execute(false);

	//窗口发生变化
	$(window).resize(function (){
		//菜单高度
		resize.sidebar();
		//路由区域高度
		resize.router();
	}).resize();

	//layer弹窗全局设置
	layer.config({
		title: '提示'
	});

	$.http.get("/index/getLoginName").then(function(res){
		if(res!=null){
			$("#deptName").html(res);
		}
	}).execute();

	//开始监听滚动条主要是隐藏时间控件弹窗
	$(".content-container-wrapper").scroll(function(){
		$(".wdate-iframe-wrapper").hide();
	});

});
